package practice;

public class practice010 {
	// 方阵90°旋转
	public static void main(String[] args) {
		int n = 5;
		int temp = 0, i, j;
		int[][] a = new int[n][n];

		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				a[i][j] = ++temp;
			}
		}

		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				System.out.println(a[i][j]);
			}
			System.out.println("\n");
		}

		System.out.println("\n\n");

		temp = 0;
		for (i = 0; i < n; i++) {
			for (j = i; j < n; j++) {
				temp = a[i][j];
				a[i][j] = a[j][i];
				a[j][i] = temp;
			}
		}
		/*
		 * for (i=0;i<n;i++) { for (j=0;j<n/2;j++) { temp=a[i][j];
		 * a[i][j]=a[i][n-1-j]; a[i][n-1-j]=temp; } }
		 */
		for (i = 0; i < n / 2; i++) {
			for (j = 0; j < n; j++) {
				temp = a[i][j];
				a[i][j] = a[n - 1 - i][j];
				a[n - 1 - i][j] = temp;
			}
		}
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				System.out.println(a[i][j]);
			}
			System.out.println("\n");
		}

	}

}
